<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/global.css" type="text/css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="css/tree.css" type="text/css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="css/main.css" type="text/css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="css/redmond/jquery-ui-1.8.16.custom.css" type="text/css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="css/jquery-ui-timepicker-addon.css" type="text/css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="css/main_style.css" type="text/css" media="screen" title="no title" charset="utf-8">

<script src="js/jquery-1.7.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery-ui-1.8.16.custom.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.blockUI.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.blockUI-css.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.tools.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.form.2.93.js" type="text/javascript" charset="utf-8"></script>
<script src="js/ui-page.js" type="text/javascript" charset="utf-8"></script>
<script src="js/common.js" type="text/javascript" charset="utf-8"></script>

<title>主界面</title>
<style>
.ErrorTip{
color:red;
}
.inputError{
border-color: red;
}
</style>
<script>
	CONTEXT_PATH = "<%=request.getContextPath()%>";
</script>
</head>
<body>
	<table id="containerTable" class="container" cellspacing="0" cellpadding="0">
		<tr style="height:80px;">
			<td class="td_container">
				<div class="page-wrapper">
					<div id="header">
						<a href="<%=request.getContextPath()%>/Index/index" id="exit" class="iconLink setting">返回</a>
					</div>
					<table cellspacing="0" cellpadding="0" class="mainContent" style="align:center;">
						<tr>
							<td align="center">
								<table cellspacing="0" cellpadding="0" class="right-list-table" width="100%;">
									<tr>
										<td style="width:30%;">&nbsp;</td>
										<td style="width:50%;">
										<br/>
										<br/>
										<br/>
										<br/>
										<br/>
										<br/>
											<h1 style="font-size: 18px;font-weight:bold;">有效天数修改</h1>
											<br/>
											<c:if test="${not empty sessionScope.licenseUpdateSuccessed }">
												<strong><font color="red">${sessionScope.licenseUpdateSuccessed ? '更新成功！' : '更新失败!'}</font></strong>
												<br/>
												<c:set var="licenseUpdateSuccessed" scope="session" value="${null}"/>
											</c:if>
											<strong><font color="green">当前License信息： ${license}</font></strong>
											<br/>
											<br/>
											<form  method="post" >
												<field class="form-field">
												<c:if test="${!license.neverExpired}">
												<label class="title">追加有效天数</label> 
												</c:if>
												<c:if test="${license.neverExpired}">
												<label class="title">有效天数</label> 
												</c:if>
												<br/>
												<input type="text" name="validDays" value="" class="long"/>
												<br/>
												<label class="title">确认口令</label> 
												<br/>
												<input type="password" name="password" value="" class="long"/>
												<br/>
												<div class="buttonRegion">
												<a class="buttonS submit" >更新有效天数</a>
												<a class="buttonS noExpired" >设置永久有效</a>
												<a class="buttonS reset" >清空</a>
												</div>
												</field>
											</form>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</div>
			</td>
		</tr>
		<tr>
			<td class="tbl-footer">
				<p>Copyright© 2011 中国移动广州分公司版权所有</p>
			</td>
		</tr>
	</table>
	<script type="text/javascript" charset="utf-8">
		$(document).ready(function(){
			
			$("a.submit").bind('click',function(){
				var validDays = $("input[name='validDays']").val();
				var password = $("input[type='password']").val().replace(/ /g,'');
				
				if (password == null  || password.length == 0) {
					alert("请输入口令!");
					return false;
				}
				if (null == /^-?[1-9]+[0-9]*$/.exec(validDays)) {
					alert("请输入合法的有效天数！");
					return false;
				}
				
				$('form').attr('action',CONTEXT_PATH+"/license/addDays");
				$('form').submit();
			});
			$('a.noExpired').bind('click',function(){
				var password = $("input[type='password']").val().replace(/ /g,'');
				if (password == null  || password.length == 0) {
					alert("请输入口令!");
					return false;
				}
				$('form').attr('action',CONTEXT_PATH+"/license/setNeverExpired");
				$('form').submit();
			});
			
			$("a.reset").bind('click',function(){
				$('form')[0].reset();
			});
		});
	</script>
</body>
</html>
